#include <algorithm>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <istream>
#include <map>
#include <vector>
using ll = int64_t;
#define printf
const ll inf=1e9+7;
ll n,anq,ans=-inf,ansi;
std::map<ll,ll> m;
std::vector<ll> l,r,w,a,b,t,xr,eq,nq;

int main(){
    std::iostream::sync_with_stdio(false);
    std::cin.tie(nullptr);

    std::cin>>n;
    l.resize(n+1);r.resize(n+1);w.resize(n+1);a.resize(n+1);b.resize(n+1);t.resize(n+1);
    m[0]=0;
    for(ll i=1;i<=n;i++){
        std::cin>>t[i];
        if(t[i]==1){
            std::cin>>l[i]>>r[i]>>w[i];
            m[l[i]-1]=m[l[i]]=m[l[i]+1]=m[r[i]-1]=m[r[i]]=m[r[i]+1]=m[r[i]+2]=0;
        }else if(t[i]==2){
            std::cin>>a[i]>>w[i];
            m[a[i]-1]=m[a[i]]=m[a[i]+1]=0;
        }else{
            std::cin>>b[i]>>w[i];
            m[b[i]-1]=m[b[i]]=m[b[i]+1]=0;
        }
    }
    ll idx=1;
    for(auto&[k,v]:m){
        v=idx++;
        printf("k=%lld, v=%lld\n",k,v);
    }
    xr.resize(idx+1);
    eq.resize(idx+1);nq.resize(idx+1);
    for(ll i=1;i<=n;i++){
        if(t[i]==1){
            ll nl=m[l[i]],nr=m[r[i]];
            xr[nl]^=w[i];
            xr[nr+1]^=w[i];
        }else if(t[i]==2){
            ll na=m[a[i]];
            eq[na]^=w[i];
        }else{
            ll nb=m[b[i]];
            nq[nb]^=w[i];
            anq^=w[i];
        }
    }
    for(ll i=1;i<=idx;i++){
        xr[i]^=xr[i-1];
    }
    auto rp=m.begin();
    for(ll i=1;i<idx;i++){
        ll nans=0;
        nans^=eq[i];
        nans^=xr[i];
        nans^=anq^nq[i];
        if(nans==ans && std::abs(rp->first)<std::abs(ansi)){
            ansi=rp->first;
            ans=nans;
        }
        if(nans>ans){
            ansi=rp->first;
            ans=nans;
        }
        rp++;
    }
    std::cout<<ans<<" "<<ansi<<"\n";
}